package com.example.demo.aspect;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Slf4j
public class AspectDemo1 {
    @Around("@annotation(com.example.demo.aspect.TimeRecord)")
    public Object TimeRecord(ProceedingJoinPoint joinPoint) {
        long start = System.currentTimeMillis();
        Object result = null;
        try {
            result = joinPoint.proceed();
        } catch (Throwable e) {
            log.error("error", e);
        }
        log.info("cost time: {} ms", System.currentTimeMillis() - start);
        return result;
    }


}
